<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>登录</title>
  <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link rel='stylesheet' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css'>
  <link rel="stylesheet" href="index.css">
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="address-resolver.js"></script>
  <script src="app.js"></script>
  <script type="text/javascript">
      function login() {
          var account = $("#email").val();
          var pwd = $("#password").val();

          if ('' == account || '' == pwd) {
              alert("请填写账户信息");
              return;
          }

          $.ajax({
              url: '/login',
              type: 'POST',
              dataType: 'JSON',
              data: {account: account, password: pwd},
              success: function (data) {
                  if ('SUCCESS' == data.successMsg) {
                      window.location.href ='list.html?username='+account;
                  } else {
                      alert("用户不存在or密码错误");
                      window.location.href = 'index.html';
                  }
              },
              error:function (data) {
                  alert("系统故障")
              }
          })
      }
  </script>
</head>
<body>

<div class="container">
  <div class="row">
    <div class="col-md-offset-3 col-md-6">
      <form class="form-horizontal">
        <span class="heading">用户登录</span>
        <div class="form-group">
          <input type="email" class="form-control" id="email" placeholder="用户名或电子邮件">
          <i class="fa fa-user"></i>
        </div>
        <div class="form-group help">
          <input type="password" class="form-control" id="password" placeholder="密　码">
          <i class="fa fa-lock"></i>
          <a href="#" class="fa fa-question-circle"></a>
        </div>
        <div class="form-group">
          <div class="main-checkbox">
            <input type="checkbox" value="None" id="checkbox1" name="check"/>
            <label for="checkbox1"></label>
          </div>
          <span class="text">记住密码</span>
          <button type="submit" class="btn btn-default" onclick="login()">登录</button>
        </div>
      </form>
    </div>
  </div>
</div>


</body>
</html>